/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nhadat.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpServletRequest;
import nhadat.xml.DatabaseAndXMLFileMappingSyncrolization;

/**
 *
 * @author Xe Bay
 */
public class NhaDatContextListener implements ServletContextListener {

    NhaDatDatabaseXMLSynchrolizeThread synThread;

    public void contextInitialized(ServletContextEvent sce) {
        synThread = new NhaDatDatabaseXMLSynchrolizeThread();

        ServletContext context = sce.getServletContext();
        String contextRealPath = context.getRealPath("/");
        synThread.setContextRealPath(contextRealPath);
        synThread.setContext(context);

        synThread.start();
    }

    public void contextDestroyed(ServletContextEvent sce) {
        synThread.setbRun(false);
    }
}
